package org.itboys.store.entity;

import org.itboys.commons.utils.random.RandomUtils;
import org.itboys.mongodb.entity.BaseLongIdEntity;
import org.itboys.store.constant.ProductConstant;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.annotations.Transient;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by huml on 2016/5/13.
 * 订单行实体
 */
@Entity(value = "StoreOrderItem", noClassnameStored = true)
public class OrderItem extends BaseLongIdEntity {

    @Indexed
    private Long orderId;//订单id
    private String itemNo;//订单行编号
    private  Long productId;//产品编号
    private String productName;//产品名称
    private String productImg;//产品主图
    private Integer num;//数量
    private int expressFee;//邮费
    private int totalFee;//原始总价
    private Date createTime;//创建时间
    private Date updateTime;//修改时间
    private Long memberId;//会员id
    private Integer status;//订单行状态 可能某个订单行交易的商品单独退款 退货之类的 待定业务

    @Transient
    private String viewFee;

    public OrderItem(){
        this.itemNo = System.currentTimeMillis() + RandomUtils.getIntRandom(6);
        this.status = ProductConstant.OrderStatic.ORDER_STATUS_CREATE;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getItemNo() {
        return itemNo;
    }

    public void setItemNo(String itemNo) {
        this.itemNo = itemNo;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductImg() {
        return productImg;
    }

    public void setProductImg(String productImg) {
        this.productImg = productImg;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public int getTotalFee() {
        return totalFee;
    }

    public void setTotalFee(int totalFee) {
        this.totalFee = totalFee;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public int getExpressFee() {
        return expressFee;
    }

    public void setExpressFee(int expressFee) {
        this.expressFee = expressFee;
    }

    public String getViewFee() {
        return new BigDecimal(totalFee).divide(new BigDecimal(100)).toString();
    }

    public void setViewFee(String viewFee) {
        this.viewFee = viewFee;
    }
}
